package com.numberma.permissionservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.numberma.permissionservice.entity.UserRoles;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface PermissionMapper extends BaseMapper<UserRoles> {
   @Select("select user_id from user_roles where role_id = #{RoleId}")
    public List<Integer> getUserIdByRoleId(int RoleId);
   @Insert("insert into user_roles(user_id,role_id) values(#{userId},#{roleId})")
    public void insertUserRole(UserRoles userRoles);
   @Select("select * from user_roles where user_id = #{userId}")
    public UserRoles  selectByUserId(Long userId);
    @Update("update user_roles set role_id = #{RoleId} where user_id = #{userId}")
    void upgradeToAdmin(Long userId,Integer RoleId);
}
